﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml;
using System.Xml.Linq;

namespace Liberty.UI
{
    /// <summary>
    /// Summary description for ThemeConfigHandler
    /// </summary>
    public class ThemeConfigHandler : IConfigurationSectionHandler
    {
        #region IConfigurationSectionHandler Members

        public object Create( object parent, object configContext, XmlNode section )
        {
            _Section = section;

            return this;
        }

        #endregion

        public string Theme( string path )
        {
            foreach( XmlNode x in _Section.ChildNodes )
            {
                if( string.Compare( path, x.Attributes["path"].Value, true ) == 0 )
                {
                    return x.Attributes["theme"].Value;
                }
            }

            return _Section.Attributes["defaultTheme"].Value;
        }

        #region Data Elements

        private XmlNode _Section;

        #endregion
    }
}